--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Commit 313a66102e39c2ff82123e596be5c924bfc41c3a
Parents : fbacdc2
Author : Ivan <ivan@quad4.io>
Signature : Signature validation error
Date : 2026-05-02T23:09:08-05:00
refactor(CommandPalette): remove unused visualizer actions and simplify action handling
Changes
2 files changed, 5 insertions(+), 131 deletions(-)
Diff
diff --git a/meshchatx/src/frontend/components/CommandPalette.vue b/meshchatx/src/frontend/components/CommandPalette.vue
index 5cf34db1..509d3de3 100644
--- a/meshchatx/src/frontend/components/CommandPalette.vue
+++ b/meshchatx/src/frontend/components/CommandPalette.vue
@@ -115,14 +115,6 @@ import LxmfUserIcon from "./LxmfUserIcon.vue";
import GlobalEmitter from "../js/GlobalEmitter";
import ToastUtils from "../js/ToastUtils";
-const VISUALISER_ONLY_ACTIONS = new Set([
- "toggle-orbit",
- "toggle-bouncing-balls",
- "toggle-falling-skies",
- "toggle-snake",
- "toggle-pong",
-]);
-
export default {
name: "CommandPalette",
components: { MaterialDesignIcon, LxmfUserIcon },
@@ -318,46 +310,6 @@ export default {
type: "action",
action: "compose",
},
- {
- id: "action-orbit",
- title: "action_orbit",
- description: "action_orbit_desc",
- icon: "orbit",
- type: "action",
- action: "toggle-orbit",
- },
- {
- id: "action-bouncing-balls",
- title: "action_bouncing_balls",
- description: "action_bouncing_balls_desc",
- icon: "bounce",
- type: "action",
- action: "toggle-bouncing-balls",
- },
- {
- id: "action-falling-skies",
- title: "action_falling_skies",
- description: "action_falling_skies_desc",
- icon: "weather-pouring",
- type: "action",
- action: "toggle-falling-skies",
- },
- {
- id: "action-snake",
- title: "action_snake",
- description: "action_snake_desc",
- icon: "snake",
- type: "action",
- action: "toggle-snake",
- },
- {
- id: "action-pong",
- title: "action_pong",
- description: "action_pong_desc",
- icon: "table-tennis",
- type: "action",
- action: "toggle-pong",
- },
{
id: "action-getting-started",
title: "action_getting_started",
@@ -379,19 +331,11 @@ export default {
},
computed: {
allResults() {
- const onVisualiser = this.$route?.name === "network-visualiser";
- const results = this.actions
- .filter((action) => {
- if (action.type === "action" && VISUALISER_ONLY_ACTIONS.has(action.action)) {
- return onVisualiser;
- }
- return true;
- })
- .map((action) => ({
- ...action,
- title: this.$t(`command_palette.${action.title}`),
- description: this.$t(`command_palette.${action.description}`),
- }));
+ const results = this.actions.map((action) => ({
+ ...action,
+ title: this.$t(`command_palette.${action.title}`),
+ description: this.$t(`command_palette.${action.description}`),
+ }));
// add peers
if (Array.isArray(this.peers)) {
@@ -536,16 +480,6 @@ export default {
const input = document.getElementById("compose-input");
input?.focus();
});
- } else if (result.action === "toggle-orbit") {
- GlobalEmitter.emit("toggle-orbit");
- } else if (result.action === "toggle-bouncing-balls") {
- GlobalEmitter.emit("toggle-bouncing-balls");
- } else if (result.action === "toggle-falling-skies") {
- GlobalEmitter.emit("toggle-falling-skies");
- } else if (result.action === "toggle-snake") {
- GlobalEmitter.emit("toggle-snake");
- } else if (result.action === "toggle-pong") {
- GlobalEmitter.emit("toggle-pong");
} else if (result.action === "show-tutorial") {
GlobalEmitter.emit("show-tutorial");
} else if (result.action === "show-changelog") {
diff --git a/tests/frontend/CommandPalette.test.js b/tests/frontend/CommandPalette.test.js
index 55e011dc..b57f615b 100644
--- a/tests/frontend/CommandPalette.test.js
+++ b/tests/frontend/CommandPalette.test.js
@@ -23,19 +23,11 @@ describe("CommandPalette.vue", () => {
};
GlobalEmitter.off("sync-propagation-node");
- GlobalEmitter.off("toggle-orbit");
- GlobalEmitter.off("toggle-falling-skies");
- GlobalEmitter.off("toggle-snake");
- GlobalEmitter.off("toggle-pong");
});
afterEach(() => {
delete window.api;
GlobalEmitter.off("sync-propagation-node");
- GlobalEmitter.off("toggle-orbit");
- GlobalEmitter.off("toggle-falling-skies");
- GlobalEmitter.off("toggle-snake");
- GlobalEmitter.off("toggle-pong");
vi.clearAllMocks();
});
@@ -254,58 +246,6 @@ describe("CommandPalette.vue", () => {
}
});
- it("emits toggle-orbit event when orbit action is executed", async () => {
- const wrapper = mountCommandPalette({ name: "network-visualiser" });
- const emitSpy = vi.spyOn(GlobalEmitter, "emit");
- wrapper.vm.isOpen = true;
- await wrapper.vm.$nextTick();
-
- const orbitResult = wrapper.vm.filteredResults.find((r) => r.action === "toggle-orbit");
- if (orbitResult) {
- wrapper.vm.executeResult(orbitResult);
- expect(emitSpy).toHaveBeenCalledWith("toggle-orbit");
- }
- });
-
- it("emits toggle-falling-skies when falling skies action is executed", async () => {
- const wrapper = mountCommandPalette({ name: "network-visualiser" });
- const emitSpy = vi.spyOn(GlobalEmitter, "emit");
- wrapper.vm.isOpen = true;
- await wrapper.vm.$nextTick();
-
- const result = wrapper.vm.filteredResults.find((r) => r.action === "toggle-falling-skies");
- if (result) {
- wrapper.vm.executeResult(result);
- expect(emitSpy).toHaveBeenCalledWith("toggle-falling-skies");
- }
- });
-
- it("emits toggle-snake when mesh snake action is executed", async () => {
- const wrapper = mountCommandPalette({ name: "network-visualiser" });
- const emitSpy = vi.spyOn(GlobalEmitter, "emit");
- wrapper.vm.isOpen = true;
- await wrapper.vm.$nextTick();
-
- const result = wrapper.vm.filteredResults.find((r) => r.action === "toggle-snake");
- if (result) {
- wrapper.vm.executeResult(result);
- expect(emitSpy).toHaveBeenCalledWith("toggle-snake");
- }
- });
-
- it("emits toggle-pong when mesh pong action is executed", async () => {
- const wrapper = mountCommandPalette({ name: "network-visualiser" });
- const emitSpy = vi.spyOn(GlobalEmitter, "emit");
- wrapper.vm.isOpen = true;
- await wrapper.vm.$nextTick();
-
- const result = wrapper.vm.filteredResults.find((r) => r.action === "toggle-pong");
- if (result) {
- wrapper.vm.executeResult(result);
- expect(emitSpy).toHaveBeenCalledWith("toggle-pong");
- }
- });
-
it("closes when ESC key is pressed", async () => {
const wrapper = mountCommandPalette();
wrapper.vm.isOpen = true;
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────